import sys, os

sys.path.append(os.getcwd())

from selenium.webdriver.common.by import By

from base.base_action import BaseAction





class CenterPage(BaseAction):
    # 个人中心

    # 设置按钮
    center_button = By.ID, "com.chebao:id/set"

    # title
    center_page_title = By.ID, "com.chebao:id/name"

    # 公告
    center_page_ann = By.ID, "com.chebao:id/xiaoxi"

    # 隐藏、显示资产
    hidden_button = By.ID, "com.chebao:id/eye_set"

    # 累计利息
    accruals_t = By.ID, "com.chebao:id/toatal2"

    # 待收利息
    accrual_t = By.ID, "com.chebao:id/eableuse"

    # 总资产
    asset_t = By.ID, "com.chebao:id/toatal"

    # 可用余额  com.chebao:id/usableamount
    remaining_t = By.ID, "com.chebao:id/usableamount"

    # 充值 com.chebao:id/chager
    pay_button = By.ID, "com.chebao:id/chager"

    # 提现 com.chebao:id/withdraw
    withdraw_button = By.ID, "com.chebao:id/withdraw"

    def click_centpage_set_button(self):
        # 点击设置按钮
        self.act_click(self.center_button)

    def click_centpage_announce_button(self):
        # 点击查看公告
        self.act_click(self.center_page_ann)

    def get_centpage_title(self):
        # 获取title
        title = self.find_element(self.center_page_title)
        return title.text

    def click_centpage_hidden(self):
        # 点击隐藏、显示资产
        self.act_click(self.hidden_button)

    def get_centpage_accruals(self):
        # 累计利息
        accruals = self.find_element(self.accruals_t)
        return accruals.text

    def get_centpage_accrual(self):
        # 待收利息
        accrual = self.find_element(self.accrual_t)
        return accrual.text

    def get_centpage_asset(self):
        # 总资产
        asset = self.find_element(self.asset_t)
        return asset.text

    def get_centpage_remaining(self):
        # 可用余额
        remaining = self.find_element(self.remaining_t)
        return remaining.text

    def click_centpage_pay(self):
        # 点击充值
        self.act_click(self.pay_button)

    def click_centpage_withdraw(self):
        # 点击提现
        self.act_click(self.withdraw_button)

    def click_centpage_borrowrecord(self):
        # 点击出借记录
        pass
